package org.lhl.readruler

import android.os.Bundle
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import io.reactivex.disposables.Disposable
import org.lhl.readruler.utils.MyLifecycleObserver
import org.lhl.readruler.utils.auto
import java.util.*

/**
 * Created by luohaolun.
 * Date: 2019/5/30
 */
open class BaseActivity : AppCompatActivity() {

    private val map = Collections.synchronizedMap(WeakHashMap<String, MyLifecycleObserver>())
    override fun onCreate(savedInstanceState: Bundle?) {
//        requestedOrientation = if (AppConfig.isLandScape) ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE else ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        super.onCreate(savedInstanceState)
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
//        window.attributes.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    }

    fun Disposable.auto(key: String? = null): Disposable {
        this.auto(key, lifecycle, map)
        return this
    }

}